package com.barunsw.bwf.neoarena_erp.repair_order_delivery;

import java.util.List;
import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.neoarena_erp.vo.RepairOrderDeliveryVo;

@Controller
@RequestMapping("/repair_order_delivery")
public class RepairOrderDeliveryController {
	private static final Logger logger = LoggerFactory.getLogger(RepairOrderDeliveryController.class);
	
	@Autowired
	private RepairOrderDeliveryService repairOrderDeliveryService;
	
	@RequestMapping(value = "/view", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		return "repair_order_delivery/repair_order_delivery";
	}
	
	@RequestMapping(value = "", method = RequestMethod.GET)
	public @ResponseBody List<RepairOrderDeliveryVo> list(
			@RequestBody @RequestParam(value="mgtDept", required=true) String mgtDept,
			@RequestBody @RequestParam(value="repairVendor", required=true) String repairVendor,
			@RequestBody @RequestParam(value="serialNo", required=false) String serialNo
			) throws Exception {
		logger.debug(String.format("list?mgtDept=%s&repairVendor=%s&serialNo=%s", mgtDept, repairVendor, serialNo));
		
		RepairOrderDeliveryVo repairOrderDeliveryVo = new RepairOrderDeliveryVo();
		repairOrderDeliveryVo.setRepairVendor(repairVendor);
		repairOrderDeliveryVo.setMgtDept(mgtDept);
		repairOrderDeliveryVo.setSerialNo(serialNo);
		
		List<RepairOrderDeliveryVo> repairOrderDeliveryList = repairOrderDeliveryService.selectList(repairOrderDeliveryVo);
		
		return repairOrderDeliveryList;
	}
	
}
